<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
 <%@page import="sdfi.lee.Entity.Enterprise"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="sdfi.lee.DAO.EnterpriseDAO"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="<c:url value='/css/common.css'></c:url>">
<script type="text/javascript" src="<c:url value='/js/jquery-1.6.js'></c:url>"></script>
<script>
	$(function(){
			
			$('div.hehe a img').css("width",'120px').css('height','100px');
			$('div.hehe>div:nth-child(odd)').addClass("enterprise_item1");
			$('div.hehe>div:nth-child(even)').addClass("enterprise_item2");
			$('button').click(function(){
				var b=$(this);
				var option={
						url:'../EpDelete',
						data:{epid:b.val()},
						dateType:"json",
						success:function(data,status){
							if(data.status=="success")
								{
							b.parents("div:first").remove();
							$('div.hehe').children("div").removeClass("enterprise_item1").removeClass("enterprise_item2");
							$('div.hehe>div:nth-child(odd)').addClass("enterprise_item1");
							$('div.hehe>div:nth-child(even)').addClass("enterprise_item2");
								}
							else
								{
								alert("对不起服务器忙！");
								}
						},
						error:function(xhr,status){
							alert("对不起服务器忙！"+status);
						}
				};
				$.ajax(option);
			});
			$("select[name=eptype]").change(function(){
				var url=$(this).attr('url')+"?eptype="+$(this).val()+"&eppg="+$(this).attr('pg');
				
			$("form").attr("action",url).submit();
				
			});
	});
	
 
	function heh(a)
	{
		alert(a);
	}
</script>
<title></title>
</head>
<body onload="">
<form action="">
	<label>企业类型选择：</label><select name="eptype" pg="1" style="height:20px" url="<c:url value='/admin/enterprisemg.jsp' />">
						<option value="1" <c:if test='${param.eptype==1}'>selected</c:if> >骨干企业</option>
						<option value="2" <c:if test='${param.eptype==2}'>selected</c:if> >参建单位</option>
						<option value="3" <c:if test='${param.eptype==3}'>selected</c:if> >区内企业</option>
						<option value="4" <c:if test='${param.eptype==4}'>selected</c:if> >国家大平台</option>
						</select>
</form>
<br>
<div class="hehe">
<%
	int etp=1;
	int pg=1;
	if(null!=request.getParameter("eptype"))
	{
		etp=Integer.valueOf(request.getParameter("eptype")).intValue();
		
	}
	if(null!=request.getParameter("pg"))
	{
		pg=Integer.valueOf(request.getParameter("pg")).intValue();
	}
 	java.util.List<Enterprise> list=new EnterpriseDAO().getAllEnterprise(etp,pg,8);
	if(null!=list&&list.size()>0)
	{
			request.setAttribute("list",list);
			
%>
	
		<c:forEach items="${requestScope.list}" var="ep">
		
			
				<div>
			<table>
				<tr>
					<c:url value="/admin/enterprisemf.jsp" var="epurl">
						<c:param name="epid" value="${ep.id}"></c:param>
					</c:url>
					<td align="left" >
						<a href="${epurl}"><img src="<c:choose>
							<c:when test="${ep.eppath==null}"><c:url value="/image/nopic.gif" /></c:when>
							<c:otherwise>${ep.eppath}</c:otherwise>
						</c:choose>"/></a>
						
					</td>
					<td>
						<a href="${epurl}">${ep.epname}</a>
					</td>
					<td align="right" style="width:10%">
					<button value="${ep.id}">x</button>
					
					</td>
				</tr>
				
			</table>
			</div>
		
		</c:forEach>
			
	<%
	}
	%>
		
		</div>
		<div class="divclear"></div>
		<div id="pages">
			
			<c:if test="${param.pg==null}">
				<c:url var="up" value="/admin/enterprisemg.jsp?eptype=${param.eptype}&pg=1">
			</c:url>
			</c:if>
			<c:if test="${param.pg!=null }">
					<c:url var="up" value="/admin/enterprisemg.jsp?eptype=${param.eptype}&pg=${param.pg-1 }">
			</c:url>
			</c:if>
		
			<c:url var="down" value="/admin/enterprisemg.jsp?eptype=${param.eptype}&pg=${param.pg+1}"></c:url>
			<font>
			<c:if test="${param.pg==1||param.pg==null}">&lt;</c:if>
			<c:if test="${param.pg!=1&&param.pg!=null}"><a href="${up}">&lt;</a></c:if></font>
			<font><c:if test="${param.pg==null}">1</c:if>
					<c:if test="${param.pg!=null}">${param.pg}</c:if>
			</font>
			<font><c:choose>
			<c:when test="${fn:length(list)<8}">&gt;</c:when>
			<c:otherwise>
			<a href="${down}">&gt;</a></c:otherwise></c:choose></font>
		</div>
		
</html>